import pkgutil
import sys

from flask import Blueprint, Flask
from flask_sqlalchemy import SQLAlchemy
from flask_login import LoginManager
from flask_migrate import Migrate

app = Flask(__name__)
db=SQLAlchemy(app)


from .model import *
migrate=Migrate(app,db)







app_dict = {}
pkg_list = pkgutil.walk_packages(__path__, __name__ + ".")
for _, module_name, ispkg in pkg_list:
    __import__(module_name)
    module = sys.modules[module_name]
    module_attrs = dir(module)
    for name in module_attrs:
        var_obj = getattr(module, name)
        if isinstance(var_obj, Blueprint):
            if app_dict.get(name) is None:
                app_dict[name] = var_obj
                app.register_blueprint(var_obj)
                print(" * 注入 %s 模块 %s 成功" % (Blueprint.__name__, var_obj.__str__()))

app.config.from_object('config')







